import React from 'react'
import {Input} from 'antd';
import MyDefineSelect from '@/components/common/myDefineSelect'
// import MySelect from '@/components/common/mySelect'
// import { useHistory } from 'react-router-dom'
// const { RangePicker } = DatePicker;

const Ftype = {
  5:'字典',
  2:'产业',
  3:'区域',
  1:'元数据',
  4:'菜单管理'
}

const getFtypeObj = (type,tableRef,formRef)=>{//type 类型   tableRef 表格 ref    formRef 表单ref
  const detaultOBj = {//区域
    //list 表格列
    listColumns:[],
    operation_id:'id',// 列表id    例子是  角色id
    params_id_key:'id',//删除调用的 参数 key
    update_id_key:'id',//更新用
    addTxt:'新增',//新增按钮文本
    listUrl:'',//列表请求url地址
    listMethod:'get',//list接口  request  method
    delUrl:'',//删除请求url地址
    addUrl:'',//新增请求url地址
    editUrl:'',//编辑请求url地址
    detailUrl:'',//详情请求url地址
    edilFields:[]//编辑弹窗详情字段
  };
  const FtypeObjS = {
    5:{//字典
      //list 表格列
      listColumns:[
        {
          type:'string',
          key:'dictindex',
          title: '字典编码',
        },
        {
          type:'string',
          key:'dicttype',
          title: '字典名称',
        },
        {
          type:'string',
          key:'optionlabel',
          title: '选项',
        },
        {
          type:'string',
          key:'optionvalue',
          title: '值',
        },
        {
          type:'operation',
          key:'operation',
          title: '操作',
        },
      ],
      operation_id:'dictid',// 列表id    例子是  角色id
      params_id_key:'id',//删除调用的 参数 key
      update_id_key:'dictid',
      addTxt:'新增字典',//新增按钮文本
      listUrl:'/dm/api/sys/dict/selectDictLabel',//列表请求url地址
      listMethod:'post',//list接口  request  method
      delUrl:'/dm/api/sys/dict/delete',//删除请求url地址
      addUrl:'/dm/api/sys/dict/add',//新增请求url地址
      editUrl:'/dm/api/sys/dict/update',//编辑请求url地址
      editMethod:'put',
      detailUrl:'/dm/api/sys/dict/detail',//详情请求url地址
      delMethod:'delete',
      deleteActionType:'string',
      deleteActionKey:'id',
      edilFields:[//编辑弹窗详情字段
        {
          key: 'dictindex',
          label:'字典编码',
          slot: <Input placeholder="请输入字典编码" />,
          rules: [
            {
              required: true,
              message: '请输入字典编码'
            }
          ],
          initialValue: ''
        },
        {
          key: 'dicttype',
          label:'字典名称',
          slot: <Input placeholder="请输入字典名称" />,
          rules: [
            {
              required: true,
              message: '请输入字典名称'
            }
          ],
          initialValue: ''
        },
        {
          key: 'optionlabel',
          label:'选项',
          slot: <Input placeholder="请输入选项" />,
          rules: [
            {
              required: true,
              message: '请输入选项'
            }
          ],
          initialValue: ''
        },
        {
          key: 'optionvalue',
          label:'值',
          slot: <Input placeholder="请输入值" />,
          rules: [
            {
              required: true,
              message: '请输入值'
            }
          ],
          initialValue: ''
        },
      ]
  },
  2:{//产业
      //list 表格列
      listColumns:[
        {
          type:'string',
          key:'industryCode',
          title: '产业代码',
        },
        {
          type:'string',
          key:'industryName',
          title: '产业名称',
        },
        {
          type:'string',
          key:'industryGroup',
          title: '产业分组',
        },
        {
          type:'operation',
          key:'operation',
          title: '操作',
        },
      ], 
      addTxt:'新增',//新增按钮文本
      listUrl:'/dm/api/baseinfo/industry/query',//列表请求url地址
      listMethod:'post',//list接口  request  method
      delUrl:'/dm/api/baseinfo/industry/delete',//删除请求url地址
      addUrl:'/dm/api/baseinfo/industry/add',//新增请求url地址
      editUrl:'/dm/api/baseinfo/industry/update',//编辑请求url地址
      editMethod:'put',
      detailUrl:'/dm/api/baseinfo/industry/info',//详情请求url地址
      delMethod:'post',
      deleteActionType:'array',
      deleteActionKey:'ids',
      operation_id:'industryCode',
      edilFields:[//编辑弹窗详情字段
        {
          key: 'industryCode',
          label:'产业代码',
          slot: <Input placeholder="请输入产业代码"/>,
          rules: [
            {
              required: true,
              message: '请输入产业代码',
            },
            
          ],
          initialValue: ''
        },
        {
          key: 'industryName',
          label:'产业名称',
          slot: <Input placeholder="请输入产业名称" />,
          rules: [
            {
              required: true,
              message: '请输入产业名称'
            }
          ],
          initialValue: ''
        },
        {
          key: 'industryGroup',
          label:'产业分组',
          slot: <Input placeholder="请输入产业分组" />,
          rules: [
            {
              required: true,
              message: '请输入产业分组'
            }
          ],
          initialValue: ''
        },
      ]
  },
  3:{//区域
    //list 表格列
    listColumns:[
      {
        type:'string',
        key:'orgManagerCode',
        title: '区域编码',
      },
      {
        type:'string',
        key:'orgManagerName',
        title: '区域名称',
      },
      {
        type:'moment',
        key:'updateTime',
        title: '修改时间',
        fotmat:'YYYY-MM-DD HH:mm'
      },
      {
        type:'operation',
        key:'operation',
        title: '操作',
      },
    ],
    operation_id:'orgManagerCode',// 列表id    例子是  角色id
    params_id_key:'id',//删除调用的 参数 key
    addTxt:'新增区域',//新增按钮文本
    listUrl:'/dm/api/baseinfo/zone/list',//列表请求url地址
    listMethod:'post',//list接口  request  method
    delUrl:'/dm/api/baseinfo/zone/delete',//删除请求url地址
    delMethod:'post',
    addUrl:'/dm/api/baseinfo/zone/add',//新增请求url地址
    editUrl:'/dm/api/baseinfo/zone/update',//编辑请求url地址
    editMethod:'put',
    detailUrl:'/dm/api/baseinfo/zone/info',//详情请求url地址
    deleteActionType:'array',
    deleteActionKey:'ids',
    edilFields:[//编辑弹窗详情字段
      {
        key: 'orgManagerCode',
        label:'区域编码',
        slot: <Input placeholder="请输入区域编码" />,
        rules: [
          {
            required: true,
            message: '请输入区域编码'
          }
        ],
        initialValue: ''
      },
      {
        key: 'orgManagerName',
        label:'区域名称',
        slot: <Input placeholder="请输入区域名称" />,
        rules: [
          {
            required: true,
            message: '请输入区域名称'
          }
        ],
        initialValue: ''
      },
      {
        key: 'orderNum',
        label:'排序号',
        slot: <Input placeholder="请输入排序号" />,
        rules: [
          {
            required: true,
            message: '请输入排序号'
          }
        ],
        initialValue: ''
      },
    ]
  },
  1:{//元数据
    //list 表格列
    listColumns:[
      {
        type:'string',
        key:'fieldName',
        title: '元数据名',
      },
      {
        type:'string',
        key:'fieldCode',
        title: '元数据编码',
      },
      {
        type:'operation',
        key:'operation',
        title: '操作',
      },
    ],
    operation_id:'id',// 列表id    例子是  角色id
    params_id_key:'id',//删除调用的 参数 key
    addTxt:'新增元数据',//新增按钮文本
    listUrl:'/dm/api/baseinfo/dtField/query',//列表请求url地址
    listMethod:'post',//list接口  request  method
    delUrl:'/dm/api/baseinfo/dtField/delete',//删除请求url地址
    delMethod:'post',
    addUrl:'/dm/api/baseinfo/dtField/add',//新增请求url地址
    editUrl:'/dm/api/baseinfo/dtField/update',//编辑请求url地址
    editMethod:'put',
    detailUrl:'/dm/api/baseinfo/dtField/info',//详情请求url地址
    deleteActionType:'array',
    deleteActionKey:'ids',
    edilFields:[//编辑弹窗详情字段
      {
        key: 'fieldName',
        label:'元数据名',
        slot: <Input placeholder="请输入元数据名" />,
        rules: [
          {
            required: true,
            message: '请输入元数据名'
          }
        ],
        initialValue: ''
      },
      {
        key: 'fieldCode',
        label:'元数据编码',
        slot: <Input placeholder="请输入元数据编码" />,
        rules: [
          {
            required: true,
            message: '请输入元数据编码'
          }
        ],
        initialValue: ''
      },
      
      {
        key: 'fieldType',
        label:'元数据类型',
        slot: <MyDefineSelect 
          url="/dm/api/sys/dict/selectDictLabel"
          params={{'dictindex':"fieldType"}}
          namekey="optionlabel"
          idkey="optionvalue"
          requestMethod="post"
          formatIdKey={(key)=>{return Number(key)}}
        />,
        rules: [
          {
            required: true,
            message: '请选择元数据类型'
          }
        ],
        initialValue: ''
      },
      {
        key: 'dataType',
        label:'数据类型',
        slot: <MyDefineSelect 
          url="/dm/api/sys/dict/selectDictLabel"
          params={{'dictindex':"dataType"}}
          namekey="optionlabel"
          idkey="optionvalue"
          requestMethod="post"
        />,
        rules: [
          {
            required: true,
            message: '请选择数据类型'
          }
        ],
        initialValue: ''
      },
    ]
  },
}




  if(FtypeObjS[type]){
    return {
      ...detaultOBj,
      ...FtypeObjS[type]
    };
  }else{
    return false;
  }
  

};






export default getFtypeObj;

export {
  Ftype
}